package com.frank.wcld.zfxc.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.wcld.zfxc.domain.WcldZfxc;
import com.frank.wcld.zfxc.service.IWcldZfxcService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 执法巡查Controller
 * 
 * @author frank
 * @date 2025-08-27
 */
@Controller
@RequestMapping("/wcld/zfxc")
public class WcldZfxcController extends BaseController
{
    private String prefix = "wcld/zfxc";

    @Autowired
    private IWcldZfxcService wcldZfxcService;

    @RequiresPermissions("wcld:zfxc:view")
    @GetMapping()
    public String zfxc()
    {
        return prefix + "/zfxc";
    }

    /**
     * 查询执法巡查列表
     */
    @RequiresPermissions("wcld:zfxc:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcldZfxc wcldZfxc)
    {
        startPage();
        List<WcldZfxc> list = wcldZfxcService.selectWcldZfxcList(wcldZfxc);
        return getDataTable(list);
    }

    /**
     * 导出执法巡查列表
     */
    @RequiresPermissions("wcld:zfxc:export")
    @Log(title = "执法巡查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcldZfxc wcldZfxc)
    {
        List<WcldZfxc> list = wcldZfxcService.selectWcldZfxcList(wcldZfxc);
        ExcelUtil<WcldZfxc> util = new ExcelUtil<WcldZfxc>(WcldZfxc.class);
        return util.exportExcel(list, "执法巡查数据");
    }

    /**
     * 新增执法巡查
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存执法巡查
     */
    @RequiresPermissions("wcld:zfxc:add")
    @Log(title = "执法巡查", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcldZfxc wcldZfxc)
    {
        wcldZfxc.setCreateBy(getLoginName());
        return toAjax(wcldZfxcService.insertWcldZfxc(wcldZfxc));
    }

    /**
     * 修改执法巡查
     */
    @RequiresPermissions("wcld:zfxc:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcldZfxc wcldZfxc = wcldZfxcService.selectWcldZfxcById(id);
        mmap.put("wcldZfxc", wcldZfxc);
        return prefix + "/edit";
    }

    /**
     * 修改保存执法巡查
     */
    @RequiresPermissions("wcld:zfxc:edit")
    @Log(title = "执法巡查", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcldZfxc wcldZfxc)
    {
        wcldZfxc.setUpdateBy(getLoginName());
        return toAjax(wcldZfxcService.updateWcldZfxc(wcldZfxc));
    }

    /**
     * 删除执法巡查
     */
    @RequiresPermissions("wcld:zfxc:remove")
    @Log(title = "执法巡查", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcldZfxcService.deleteWcldZfxcByIds(ids));
    }
}
